// Purpose : This page is showing rating of a doctor
// Date    : 28 Oct, 2007
// Author  : Vinayak Singh Rathore
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using SiteManager;
public partial class DashBoard_myRating : System.Web.UI.Page
{  
    localFunction lfunction = new localFunction();
    int iUserId = 0;    
    protected void Page_Load(object sender, EventArgs e)
    {
        //Check User login
        if (!Page.IsPostBack)
        {
            lfunction.checkDoctorandDentisLogin(true);
            if (Session["userID"] != null && Session["userID"].ToString() != "")
            {
                iUserId = Convert.ToInt32(Session["userID"]);
            }
            else
            {
                iUserId = 0;
            }

            BindMyRatingDoc();
         


        }
    }
    /// <summary>
    /// private void BindMyRatingDoc()
    /// <author>Vinayak Singh Rathore</author>
    /// <date>28 Oct, 2007</date>
    /// </summary>
    private void BindMyRatingDoc()
    {
        System.Data.DataSet ds = GetMyRatingDenByUserId(iUserId);
        if (ds.Tables[0].Rows.Count > 0)
        {
            lblDoctor.Text = "<b>Your Rating</b>";
            grdMyRating.DataSource = ds;
            grdMyRating.DataBind();            
        }
        else
        {            
            lblDoctor.Text = "";
            lblMsg.Text = "No Records found";
            lblMsg.ForeColor = System.Drawing.Color.Red;
            lblMsg.Font.Bold = true;
        }
    }
    /// <summary>
    ///  public System.Data.DataSet GetMyRatingDenByUserId(int Userid)
    /// </summary>
    /// <author>Vinayak Singh Rathore</author>
    /// <param name="Userid"></param>
    /// <returns></returns>
    public System.Data.DataSet GetMyRatingDenByUserId(int Userid)
    {
        Manager objManager = new Manager(true,"ConnectionString");
        SqlParameter[] _SqlparameterObject = null;
         int userType = 1;
        if ((Session["userType"].ToString() == "Doctor") && ((Convert.ToString(Session["DoctorType"]).Length == 0)))
            userType = 2;
        else if (Session["userType"].ToString() == "SiteUser")
            userType = 3;
        else if ((Session["userType"].ToString() == "Doctor") && (Convert.ToString(Session["DoctorType"]) == "Dentist"))
            userType = 4;

        try
        {
            _SqlparameterObject = new SqlParameter[2];
            _SqlparameterObject[0] = new SqlParameter("@UserId", Userid);
            _SqlparameterObject[1] = new SqlParameter("@UserType",SqlDbType.Int);
            _SqlparameterObject[1].Value = userType;
            DataSet ds = objManager.ExecuteQuery("[GetMyRatingForADoctorandDentist]", _SqlparameterObject, "tblMyDoc");
            objManager = null;
            return ds;
        }
        catch (Exception ex)
        {

            throw (ex);
        }
        finally
        {

            _SqlparameterObject = null;
        }
    }
}
